Using linq to parse file [closed]

Posted by Emaan Abdul majeed on Programmers See other posts from Programmers or by Emaan Abdul majeed
Published on 2012-09-29T19:01:03Z Indexed on 2012/09/29 21:49 UTC
Read the original article Hit count: 207

Filed under:
|
|
|

i am working parsing textfile using LINQ but got struc on it,its going outof range exception

 string[] lines = File.ReadAllLines(input);
            var t1 = lines
                .Where(l => !l.StartsWith("#"))
                .Select(l => l.Split(' '))
                .Select(items => String.Format("{0}{1}{2}",
                    items[1].PadRight(32),
                    //items[1].PadRight(16)
                    items[2].PadRight(32),
                    items[3].PadRight(32)));
            var t2 = t1
                .Select(l => l.ToUpper());
            foreach (var t in t2)
                Console.WriteLine(t);

and file is about 200 to 500 lines and i want to extract specific information so i need to split that information to different structure so how to do it this..

© Programmers or respective owner

Related posts about c#

Related posts about .NET